package com.hzf.workman.rpc.service.impl;

import com.hzf.workman.dao.mapper.*;
import com.hzf.workman.dao.model.*;
import com.hzf.workman.rpc.api.WorkmanApiService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class WorkmanApiServiceImpl implements WorkmanApiService {
    @Autowired
    WorkmanManinfoMapper workmanWorkmanManinfoMapper;
    @Autowired
    WorkmanManinfoCaseMapper workmanWorkmanManinfoCaseMapper;
    @Autowired
    WorkmanDemandMapper workmanDemandMapper;
    @Autowired
    WorkmanBidMapper workmanBidMapper;
    @Autowired
    WorkmanDemandSjtMapper workmanDemandSjtMapper;
    @Autowired
    WorkmanDemandWltMapper workmanDemandWltMapper;
    @Autowired
    WorkmanManinfoJinengMapper workmanManinfoJinengMapper;
    @Override
    public WorkmanManinfo installWorkmanManinfo(WorkmanManinfo workmanWorkmanManinfo) {
        WorkmanManinfoExample example = new WorkmanManinfoExample();
        example.createCriteria().andUserIdEqualTo(workmanWorkmanManinfo.getUserId());
        List<WorkmanManinfo> list = workmanWorkmanManinfoMapper.selectByExample(example);
        if (0 != list.size()) {
            return null;
        }
        workmanWorkmanManinfoMapper.insert(workmanWorkmanManinfo);
        return workmanWorkmanManinfo;
    }
    @Override
    public List<WorkmanManinfo> selectWorkmanManinfo(WorkmanManinfoExample workmanWorkmanManinfoExample) {
        return workmanWorkmanManinfoMapper.selectByExample(workmanWorkmanManinfoExample);
    }

    @Override
    public WorkmanManinfo getWorkmanManinfo(WorkmanManinfoExample workmanWorkmanManinfoExample) {

        List<WorkmanManinfo> list = workmanWorkmanManinfoMapper.selectByExample(workmanWorkmanManinfoExample);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanManinfo(WorkmanManinfo workmanWorkmanManinfo) {
        return workmanWorkmanManinfoMapper.updateByPrimaryKey(workmanWorkmanManinfo);
    }

    @Override
    public int delectWorkmanManinfo(WorkmanManinfo workmanWorkmanManinfo) {
        return workmanWorkmanManinfoMapper.deleteByPrimaryKey(workmanWorkmanManinfo.getId());
    }

    @Override
    public List<WorkmanManinfo> selectByPrimaryWorkmanManinfo(int regionNumber, int status, long min0, long max0, long min1, long max1, long min2, long max2, long min3, long max3, long min4, long max4, long min5, long max5, long min6, long max6, long min7, long max7, long min8, long max8) {
        return workmanWorkmanManinfoMapper.selectByPrimaryWorkmanManinfo(regionNumber,status, min0,max0,min1,max1,min2,max2,min3,max3,min4,max4,min5,max5,min6,max6,min7,max7,min8,max8);
    }
    @Override
    public List<WorkmanDemand> selectByPrimaryWorkmanDemand(int regionNumber, int status, long min0, long max0, long min1, long max1, long min2, long max2, long min3, long max3, long min4, long max4, long min5, long max5, long min6, long max6, long min7, long max7, long min8, long max8) {
        return workmanDemandMapper.selectByPrimaryWorkmanDemand(regionNumber,status, min0,max0,min1,max1,min2,max2,min3,max3,min4,max4,min5,max5,min6,max6,min7,max7,min8,max8);
    }
    @Override
    public int installWorkmanManinfoCase(WorkmanManinfoCase workmanWorkmanManinfo) {
        WorkmanManinfoCaseExample example = new WorkmanManinfoCaseExample();
        example.createCriteria().andUserIdEqualTo(workmanWorkmanManinfo.getUserId());
        List<WorkmanManinfoCase> list = workmanWorkmanManinfoCaseMapper.selectByExample(example);
        if (0 != list.size()) {
            return 0;
        }
        return workmanWorkmanManinfoCaseMapper.insert(workmanWorkmanManinfo);
    }
    @Override
    public List<WorkmanManinfoCase> selectWorkmanManinfoCase(WorkmanManinfoCaseExample workmanWorkmanManinfoCaseExample) {
        return workmanWorkmanManinfoCaseMapper.selectByExample(workmanWorkmanManinfoCaseExample);
    }

    @Override
    public WorkmanManinfoCase getWorkmanManinfoCase(WorkmanManinfoCaseExample workmanWorkmanManinfoCaseExample) {

        List<WorkmanManinfoCase> list = workmanWorkmanManinfoCaseMapper.selectByExample(workmanWorkmanManinfoCaseExample);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanManinfoCase(WorkmanManinfoCase workmanWorkmanManinfo) {
        return workmanWorkmanManinfoCaseMapper.updateByPrimaryKey(workmanWorkmanManinfo);
    }

    @Override
    public int delectWorkmanManinfoCase(WorkmanManinfoCase workmanWorkmanManinfo) {
        return workmanWorkmanManinfoCaseMapper.deleteByPrimaryKey(workmanWorkmanManinfo.getId());
    }
    @Override
    public int installWorkmanDemand(WorkmanDemand data) {

        return workmanDemandMapper.insert(data);
    }
    @Override
    public List<WorkmanDemand> selectWorkmanDemand(WorkmanDemandExample data) {
        return workmanDemandMapper.selectByExample(data);
    }

    @Override
    public WorkmanDemand getWorkmanDemand(WorkmanDemandExample data) {

        List<WorkmanDemand> list = workmanDemandMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanDemand(WorkmanDemand data) {
        return workmanDemandMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectWorkmanDemand(WorkmanDemand data) {
        return workmanDemandMapper.deleteByPrimaryKey(data.getId());
    }

    @Override
    public int installWorkmanBid(WorkmanBid data) {
        WorkmanBidExample example = new WorkmanBidExample();
        example.createCriteria().andUserIdEqualTo(data.getUserId()).andDemandIdEqualTo(data.getDemandId());
        List<WorkmanBid> lists = workmanBidMapper.selectByExample(example);
        if(null!=lists&&0!=lists.size()){
            return 0;
        }
         return workmanBidMapper.insert(data);
    }

    @Override
    public List<WorkmanBid> selectWorkmanBid(WorkmanBidExample data) {
        return workmanBidMapper.selectByExample(data);
    }

    @Override
    public WorkmanBid getWorkmanBid(WorkmanBidExample data) {
        List<WorkmanBid> list = workmanBidMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanBid(WorkmanBid data) {
        return workmanBidMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectWorkmanBid(WorkmanBid data) {
        return workmanBidMapper.deleteByPrimaryKey(data.getId());
    }
    @Override
    public int installWorkmanDemandSjt(WorkmanDemandSjt data) {
        WorkmanDemandSjtExample example = new WorkmanDemandSjtExample();
        example.createCriteria().andDemandIdEqualTo(data.getDemandId());
        List<WorkmanDemandSjt> lists = workmanDemandSjtMapper.selectByExample(example);
        if(null!=lists&&0!=lists.size()){
            return 0;
        }
        return workmanDemandSjtMapper.insert(data);
    }

    @Override
    public List<WorkmanDemandSjt> selectWorkmanDemandSjt(WorkmanDemandSjtExample data) {
        return workmanDemandSjtMapper.selectByExample(data);
    }

    @Override
    public WorkmanDemandSjt getWorkmanDemandSjt(WorkmanDemandSjtExample data) {
        List<WorkmanDemandSjt> list = workmanDemandSjtMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanDemandSjt(WorkmanDemandSjt data) {
        return workmanDemandSjtMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectWorkmanDemandSjt(WorkmanDemandSjt data) {
        return workmanDemandSjtMapper.deleteByPrimaryKey(data.getId());
    }
    @Override
    public int installWorkmanDemandWlt(WorkmanDemandWlt data) {
        WorkmanDemandWltExample example = new WorkmanDemandWltExample();
        example.createCriteria().andDemandIdEqualTo(data.getDemandId());
        List<WorkmanDemandWlt> lists = workmanDemandWltMapper.selectByExample(example);
        if(null!=lists&&0!=lists.size()){
            return 0;
        }
        return workmanDemandWltMapper.insert(data);
    }

    @Override
    public List<WorkmanDemandWlt> selectWorkmanDemandWlt(WorkmanDemandWltExample data) {
        return workmanDemandWltMapper.selectByExample(data);
    }

    @Override
    public WorkmanDemandWlt getWorkmanDemandWlt(WorkmanDemandWltExample data) {
        List<WorkmanDemandWlt> list = workmanDemandWltMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanDemandWlt(WorkmanDemandWlt data) {
        return workmanDemandWltMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectWorkmanDemandWlt(WorkmanDemandWlt data) {
        return workmanDemandWltMapper.deleteByPrimaryKey(data.getId());
    }
    @Override
    public int installWorkmanManinfoJineng(WorkmanManinfoJineng data) {
        return workmanManinfoJinengMapper.insert(data);
    }

    @Override
    public List<WorkmanManinfoJineng> selectWorkmanManinfoJineng(WorkmanManinfoJinengExample data) {
        return workmanManinfoJinengMapper.selectByExample(data);
    }

    @Override
    public WorkmanManinfoJineng getWorkmanManinfoJineng(WorkmanManinfoJinengExample data) {
        List<WorkmanManinfoJineng> list = workmanManinfoJinengMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateWorkmanManinfoJineng(WorkmanManinfoJineng data) {
        return workmanManinfoJinengMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectWorkmanManinfoJineng(WorkmanManinfoJineng data) {
        return workmanManinfoJinengMapper.deleteByPrimaryKey(data.getId());
    }
}
